#!/bin/sh
if [ -n "GAMEDIR/lib" ] ; then
	if [ "${LD_LIBRARY_PATH+set}" = "set" ] ; then
		export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:GAMEDIR/lib"
	else
		export LD_LIBRARY_PATH="GAMEDIR/lib"
	fi
fi
if [[ ! -e ~/.defcon/lib ]] ; then
	mkdir -p ~/.defcon/lib \
	    && cd ~/.defcon/lib \
	    && ln -s "GAMEDIR"/lib/* .
fi
cd ~/.defcon/lib
LD_PRELOAD="GAMEDIR/lib/chdir.so" exec ./defcon.bin.x86 "$@"
